package leetcode;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * User: Ghost
 * Date: 14-6-13
 * Time: 下午8:55
 * To change this template use File | Settings | File Templates.
 */
public class Remove_Element {
    public int removeElement(int[] A, int elem) {
        int count = 0;
        int[] B = new int[A.length];
        for(int i=0;i<A.length;i++){
            if(A[i]!=elem) {
                B[count] = A[i];
                count++;
            }
        }
        for(int i=0;i<count;i++){
            A[i] = B[i];
        }
        return count;
    }
    public static void main(String[] args){
        Remove_Element remove_element = new Remove_Element();
        int[] A = {4,5};

        System.out.println(remove_element.removeElement(A, 4));
        System.out.println(A[0]);
    }
}
